﻿using Agile.Infra.IdGenerator.Configurations;
using Agile.Infra.IdGenerator.Yitter;
using Microsoft.Extensions.Configuration;

namespace Microsoft.Extensions.DependencyInjection;

public static class ServiceCollectionExtension
{
    public static IServiceCollection AddAgileIdGenerater(this IServiceCollection services, IConfigurationSection section)
    {
        if (services.HasRegistered(nameof(AddAgileIdGenerater)))
            return services;

        var idOptions = section.Get<IdOptions>();
        IdGenerater.Init(idOptions.WorkerID); 
        return services;
    }
}
